<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>方维网站后台管理系统_深圳网站建设</title>
        <meta name="author" content="深圳方维网络科技有限公司 http://www.szfangwei.cn" />
    <import type="css" file="admin/css/index" />
    <import type="js" file="common/jquery171min" />
    <import type="css" file="common/uploadify/uploadify" />
    <script language="javascript" type="text/javascript">
        document.write("<script type='text/javascript' " + "src='__PUBLIC__/common/uploadify/min.js?" + new Date() + "'></s" + "cript>");
    </script>
</head>
<body> 
    <div class="list">
        <div>
            <div style="float:left"><input type="file" id="uploadeditor_img" name="uploadeditor_img" />
                <input type="hidden" id="editor_img" name="editor_img" value="" /></div><div class="c"></div>
                <div id="diveditor_img" class="piclist" style=" margin:10px 0px;">
            </div>
            <div class="c"></div>
        </div>
        <script type="text/javascript">
            var value = "";
            if (value == "")
            {
                $("#diveditor_img").hide();
            }
            $('#uploadeditor_img').uploadify({
                'swf': '__PUBLIC__/common/uploadify/uploadify.swf")',
                'uploader': "{:U('Fwadmin/Login/uploadMorePic')}?path=editor/img&sessionid={:session_id()}",
                'cancelImg': '__PUBLIC__/common/uploadify/uploadify-cancel.png',
                'buttonText': '选择多张图片',
                'auto': true,
                'multi': true, //允许上传多图
                'height': 24,
                'width': 120,
                'fileTypeDesc': '图片文件',
                'fileTypeExts': '*.jpg;*.gif;*.png;*.bmp;',
                'fileSizeLimit': '2024KB',
                'removeTimeout': 0,
                'onUploadError': function(file, errorCode, errorMsg, errorString, swfuploadifyQueue) {
                    if (errorCode !== "-280" && errorMsg !== "File Upload Cancelled.")
                    {
                        alert(errorMsg);
                    }
                },
                'onCancel': function(event, queueID, file, data) {
                    //  alert("取消成功！");
                },
                'onUploadComplete': function(file) { //每个文件上传完成

                },
                'onUploadSuccess': function(file, data, response) {
                    //　　alert(file+'-'+data+'--'+response);
                    if (response == true) {
                        var json = eval('(' + data + ')');
                        if (json.SaveName != undefined)
                        {
                            $("#editor_img").val($("#editor_img").val() + json.SaveName + ',');
                            showMorePic($("#editor_img").val());
                        }
                    }
                    else {
                        alert("上传出错！");
                    }
                }
            });

            //uploadify上传多文件删除文件
            function delfile2(filename, i) {
                if (filename !== '')
                {
                    $.ajax({
                        url: "{:U('Fwadmin/Index/delPic')}?filename=" + filename,
                        success: function(val)
                        {
                            var old_val = $("#editor_img").val();
                            var new_val = old_val.replace(filename + ',', '');
                            $("#editor_img").val(new_val);
                            $("#showpic" + i).hide();
                        }
                    });
                }
            }
            function showMorePic(str)　 {
                var html = '';
                if (str !== '')
                {
                    str = str.substring(0, str.length - 1);
                    var pics = str.split(',');
                    
                    for (var i = 0; i < pics.length; i++)
                    {
                        if (pics[i] !== '')
                        {
                            html += '<dl id="showpic' + i + '" val="' + pics[i] + '"><dt><a href="__ROOT__' + pics[i] + '" target="_blank"><img src="__ROOT__' + pics[i] + '" width="100px" height="115px" alt="点击查看原图"  /></a></dt><dd><a href="#" onclick="delfile2(\'' + pics[i] + '\',' + i + ')">删除</a></dd></dl>';
                           // parent.moreimgs.push('__ROOT__'+pics[i]);
                        }
                    }
                    
                    parent.moreimgs = pics;
                     for (var i = 0; i < parent.moreimgs.length; i++)
                    {
                        parent.moreimgs[i] = '__ROOT__'+parent.moreimgs[i];
                    }
                   //  alert('pics:'+pics.length+"-moreimgs:"+parent.moreimgs.length);
                    $("#diveditor_img").html(html);
                    $("#diveditor_img").show();
                } else {
                    $("#diveditor_img").html(html);
                    $("#diveditor_img").hide();
                }
            }
        </script>
    </div>
</body>
</html>